<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList">
        <template slot-scope="scope" slot="menuLeft">
          <el-button type="primary"
                     size="small"
		     v-if="false"
                     @click.stop="handleExport()">导 出
          </el-button>
          <el-button type="primary"
                     size="small"
                     :hidden="true"
                     v-if="false"
                     @click.stop="handlePrint()">打 印
          </el-button>
        </template>
        <template slot="menu" slot-scope="{ row, index }">
          <el-button
            type="text"
            size="small"
            icon="el-icon-edit"
            v-permission="permissionList.editBtn"
            @click="rowEdit(row, index)"
          >编辑
          </el-button>
	  <el-button type="text" size="small"
            v-permission="permissionList.delBtn"
            @click="rowDel(row, index)">删 除</el-button>
        </template>
        <template slot="header" slot-scope="scope">
          <el-radio-group v-model="params.ticketType" style="margin-bottom: 15px;">
            <el-radio-button v-for="type in ticketTypeList"
              :label="type.mainEnName"
              :key="type.mainEnName">{{type.mainName}}
            </el-radio-button>
          </el-radio-group>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import baseCrud from '@/mixins/base-crud'
import { getDict as getTicketTypeDict } from '@/api/support/swpmticketcardtype'
import { getDictAll as getTicketNameDict } from '@/api/support/swpmticketcardtypeparam'
import { delObj } from '@/api/subway/swststockdaycheckdetail'
import { startDate, endDate } from "@/const/crud/subway/swststockdaycheckdetail";

export default {
  name: 'SwStStockDayCheckDetail',
  mixins: [baseCrud('subway/swststockdaycheckdetail')],
  data() {
    return {
      exportName: '车票出入库与结存情况.xlsx',
      ticketTypeList: [],
      params: {
        ticketType: null
      },
      searchForm: {
        dates1: [startDate, endDate]
      }
    }
  },
  computed: {
    permissionList() {
      return {
        editBtn: this.vaildData(this.permissions.st_stock_Day_detail_update,false),
	delBtn: this.vaildData(this.permissions.st_stock_Day_detail_delete,false)
      }
    }
  },
  watch: {
    'params.ticketType'(val){
      this.searchForm.ticketName = null
      this.$refs.crud.searchForm.ticketName = null
      this.getList(this.page)
      getTicketNameDict(val).then(response => {
        this.$set(this.$refs.crud.DIC, 'ticketName', response.data.data)
      })
    }
  },
  created(){
    getTicketTypeDict().then(response => {
      this.ticketTypeList = response.data.data
      this.params.ticketType = this.ticketTypeList[0].mainEnName
    })
  },
  methods: {
      rowDel(row, index){     
       this.$confirm('是否删除该数据？')
          .then(_ => {
            delObj(row).then(() => {
            this.$message.success('删除成功')
            this.getList(this.page)
            })
          })
          .catch(_ => {});
      
      }

  }
}
</script>

<style lang="scss" scoped>
</style>
